package gr.unipi.mscd1;

import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;

import javax.swing.JTextArea;
public class RamSize extends SnmpInfo implements SnmpValuesListener {
	
	private ArrayList<OidInfo> OIDs;
	
	private JTextArea textArea;
	
	public RamSize(SimpleSnmpClient client, JTextArea txt) {
		super(client);
		this.textArea = txt;
		this.addSnmpValueListener(this);
		OIDs = new ArrayList<OidInfo>() {
			private static final long serialVersionUID = 1L;

			{
				add(new OidInfo(OidConsts.hrMemorySize, false, ParamType.INT, textArea));
			}
		};
		initialize();
	}
	
	@Override
	protected List<OidInfo> getOids() {
		return OIDs;
	}

	@Override
	public void valuesRetrieved(Object sender) {
		int ramKb = Integer.parseInt(textArea.getText());
		double ramMb = ((double)ramKb) / 1024.0;
		
		DecimalFormat df = new DecimalFormat("###.##");
		textArea.setText(df.format(ramMb));
	}

}
